/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author The Lunatics
 */
@Entity
@Table(name = "user_preferences")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "UserPreferences.findAll", query = "SELECT u FROM UserPreferences u"),
    @NamedQuery(name = "UserPreferences.findById", query = "SELECT u FROM UserPreferences u WHERE u.userPreferencesPK.id = :id"),
    @NamedQuery(name = "UserPreferences.findByPreference", query = "SELECT u FROM UserPreferences u WHERE u.userPreferencesPK.preference = :preference")})
public class UserPreferences implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected UserPreferencesPK userPreferencesPK;
    @JoinColumn(name = "Id", referencedColumnName = "User_Id", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Users users;

    public UserPreferences() {
    }

    public UserPreferences(UserPreferencesPK userPreferencesPK) {
        this.userPreferencesPK = userPreferencesPK;
    }

    public UserPreferences(int id, String preference) {
        this.userPreferencesPK = new UserPreferencesPK(id, preference);
    }

    public UserPreferencesPK getUserPreferencesPK() {
        return userPreferencesPK;
    }

    public void setUserPreferencesPK(UserPreferencesPK userPreferencesPK) {
        this.userPreferencesPK = userPreferencesPK;
    }

    public Users getUsers() {
        return users;
    }

    public void setUsers(Users users) {
        this.users = users;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (userPreferencesPK != null ? userPreferencesPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof UserPreferences)) {
            return false;
        }
        UserPreferences other = (UserPreferences) object;
        if ((this.userPreferencesPK == null && other.userPreferencesPK != null) || (this.userPreferencesPK != null && !this.userPreferencesPK.equals(other.userPreferencesPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.UserPreferences[ userPreferencesPK=" + userPreferencesPK + " ]";
    }
    
}
